<template>
	<view class="list_box">
		<view class="search">
			<view class="search-content">
				<uni-icons type="search" size="26" color="#9F9F9F"></uni-icons>
				<input type="text" class="S-input" placeholder="请输入关键词..." focus>
			</view>
		</view>
		<view class="left" style='display: inline-block;'>
			<scroll-view scroll-y="true" :style="{ 'height':scrollHeight }">
				<view class="item" v-for="(item,index) in leftArray" :key="index" :class="active==index?'active':'' "
					:data-index="index" @tap="leftTap(item,index)">{{item}}</view>
			</scroll-view>
		</view>

		<view class="big">
			<view class="timeBottom" v-for="(item,index) in timesList" :key="index" :class="show==index?'show':'no'" style='height: 300rpx;'>
				<view class="timeItem" v-for="(item,index) in item.data" :key="index" @tap.stop="fun3(item,index)" style='height: 300rpx;'>
					<img :src="item.timesUrl"></img>
					<view class="ming">
						<text class="timeText3">{{item.title}}</text>
					</view>
				</view>
			</view>
		</view>

	</view>

</template>
<script>
	import {
		mapState,
		mapGetters,
		mapActions,
		mapMutations
	} from 'vuex'
	export default {
		data() {
			return {
				scrollHeight: '500px',
				leftArray: ['推荐', '箱包', '男装', '女装', '鞋子', '裤子', '汽车', '食品', '维修', '机票', '安装', '图书', '宠物'],
				// mainArray: [{
				// 	url: '../../static/0fd.jpg',
				//   },
				// ],

				leftIndex: 0,
				show: 0,
				active: 0
			}
		},
		computed: {
			...mapState([
				'timesList'
			])
		},
		onLoad() {
			/* 设置当前滚动容器的高，若非窗口的高度，请自行修改 */
			uni.getSystemInfo({
				success: (res) => {
					this.scrollHeight = `${res.windowHeight}px`;
				}
			});
		},
		methods: {
			/* 左侧导航点击 */
			leftTap(item, index) {
				this.active = index
				this.show = index
			},
			fun3(item,index) {
				uni.navigateTo({
					url: `../detail/detail?arr=${JSON.stringify(item)}`
				});
			}
			/* 轮播图切换 */
			// swiperChange(e) {
			// 	let index = e.detail.current;
			// 	this.leftIndex = Number(index);
			// }
		}
	}
</script>
<style lang='scss' scoped>
	.list_box {
		/* display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		justify-content: flex-start;
		align-items: flex-start;
		align-content: flex-start;
		font-size: 28rpx;
 */

		.search {
			width: 100%;
			height: 100rpx;
			display: flex;
			align-items: center;


			.search-content {
				width: 90%;
				height: 70rpx;
				margin: auto;
				border: 1px solid #E6E6E6;
				border-radius: 100rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				color: #9F9F9F;

				text {
					margin-left: 10rpx;
				}
			}
		}

		.left {
			width: 200rpx;
			height: 100%;
			background-color: #f6f6f6;
			line-height: 100rpx;
			box-sizing: border-box;
			font-size: 32rpx;
			position: fixed;
			overflow-y: scroll;

			.item {
				padding-left: 20rpx;
				position: relative;
				width: 100%;

				&:not(:first-child) {
					margin-top: 1px;

					&::after {
						content: '';
						display: block;
						height: 0;
						border-top: #d6d6d6 solid 1px;
						width: 620upx;
						position: absolute;
						top: -1px;
						right: 0;
						transform: scaleY(0.5);
						/* 1px像素 */
					}
				}

				&.active,
				&:active {
					color: #42b983;
					background-color: #fff;
				}
			}
		}

	}

	.big {

		position: relative;
		height: 900px;
		float: right;
		width: 70%;
		margin-bottom: 30px;
	}

	.timeBottom.no {
		display: none;
	}

	.timeBottom.show {
		display: block;
		display: flex;
		justify-content: space-around;
		flex-wrap: wrap;
	}

	.timeBottom {
		/* display: none; */
		position: absolute;
		/* width: 70%; */
		height: 100%;
		display: flex;
		justify-content: space-around;
		flex-wrap: wrap;
		/* float: right; */


		.timeItem {
			width: 40%;
			justify-content: space-around;
			display: flex;
			flex-direction: column;
			align-items: center;
			/* border: 1px solid #c3c0ca; */
			box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
			margin-top: 10rpx;

			img {
				width: 200rpx;
				height: 200rpx;
			}

			.ming {
				text-align: center;
			}

			.timeText {
				display: flex;
				justify-content: space-between;
				font-size: 14px;

				.timeText2 {
					color: #9F9F9F;
					text-decoration: line-through;
				}
			}
		}
	}
</style>